const mysql = require("mysql2");

const connection = mysql.createConnection({
  host: "localhost",
  port: 3306,
  user: "root",
  password: "root",
  database: "node_mysql2",
});

const statement = `insert into products set ?`; // ? 表示占位符
const phoneJson = require("./phone.json");

for (let phone of phoneJson) {
  connection.query(statement, phone); // 执行插入操作，将json中的数据插入到数据库中
}
